package com.netease.course.web.controller;

import java.io.IOException;
import java.io.Writer;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloController {


	@RequestMapping(value="/users/{userId}")
	public void spring(@PathVariable("userId")String userId,@RequestParam("msg") String
			 msg,@RequestHeader("host") String host,Writer writer) throws IOException{
		writer.write("userId="+userId+",msg="+msg+",hostHeader="+host);
	}
	
	@RequestMapping(value="/users/login/*")	
	public String spring(String userId, String userName,ModelMap map) throws IOException{
		String user1Name="test1";String user1Id="1001";
		String user2Name="test2";String user2Id="1002";
		String user3Name="test3";String user3Id="1003";
		String user4Name="test4";String user4Id="1004";
		
		map.addAttribute("user1Id",user1Id);
		map.addAttribute("user1Name",user1Name);
		
		map.addAttribute("user2Id",user2Id);
		map.addAttribute("user2Name",user2Name);
		
		map.addAttribute("user3Id",user3Id);		
		map.addAttribute("user3Name",user3Name);
		
		map.addAttribute("user4Id",user4Id);
		map.addAttribute("user4Name",user4Name);
		
		
		
		return "user";
	}
}
